<?php if (!defined('THINK_PATH')) exit();?><!DOCTYPE html>
<html>
    
    <head>
        <meta charset="utf-8">
        <title>
            <?php echo $title ?>-<?php echo C('TITLE'); ?>
        </title>
        <meta name="renderer" content="webkit">
        <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
        <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
        <link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />
        <meta name="apple-mobile-web-app-status-bar-style" content="black">
        <meta name="apple-mobile-web-app-capable" content="yes">
        <meta name="format-detection" content="telephone=no">
        <link rel="stylesheet" href="/project/guangqiang/Public/X-admin/css/x-admin.css" media="all">
        <script src="/project/guangqiang/Public/X-admin/js/jquery.min.js" charset="utf-8">
        </script>
        <script src="/project/guangqiang/Public/X-admin/lib/layui/layui.js" charset="utf-8">
        </script>
        <script src="/project/guangqiang/Public/X-admin/js/del.js"></script>
        <script src="/project/guangqiang/Public/X-admin/js/x-admin.js"></script>
        <script src="/project/guangqiang/Public/X-admin/js/x-layui.js"></script>
        
    </head>


<body>
    <div class="x-body">
        <form class="layui-form layui-form-pane">
            <div class="layui-form-item">
                <label for="L_title" class="layui-form-label">
                    标题
                </label>
                <div class="layui-input-block">
                    <input type="text" id="L_title" name="title" required lay-verify="title" value="<?php echo $question['title']; ?>" 
                    autocomplete="off" class="layui-input">
                </div>
            </div>
            <input type="hidden" name='qid' value="<?php echo $question['qid']; ?>">
            <div class="layui-form-item layui-form-text">
                <div class="layui-input-block">
                    <textarea id="L_content" name="content" 
                    placeholder="请输入内容" class="layui-textarea fly-editor" style="height: 260px;"> <?php echo $question['content']; ?></textarea>
                </div>
                <label for="L_content" class="layui-form-label" style="top: -2px;">
                    描述
                </label>
            </div>
            <div class="layui-form-item">
                <div class="layui-inline">
                    <label class="layui-form-label">
                        所在类别
                    </label>
                    <div class="layui-input-block">
                        <select lay-verify="required" name="cid">
                            <option>
                            </option>
                             <?php  foreach ($newcate as $v){ ?>
                            <optgroup label="<?php echo $v['cname']; ?>">
                               <?php foreach ($v['son'] as $son){ ?>
                                    <option 
                                    <?php if($question['cname']==$son['cname']): ?>
                                        selected
                                    <?php endif; ?> 
                                    value="<?php echo $son['cid'] ?>"><?php echo $son['cname']; ?>
                                    </option>
                                <?php } ?>
                            </optgroup>
                          <?php }?>
                        </select>
                    </div>
                </div>
                <div class="layui-inline">
                    <label class="layui-form-label">
                        帖子级别
                    </label>
                    <div class="layui-input-block">
                        <select lay-verify="required" name="level">
                            <option>
                            </option>
                              <option value="0" <?php if($question['level']==0){ ?>
                                  selected
                              <?php } ?>>正常帖子</option>
                              <option value="1" <?php if($question['level']==1){ ?>
                                  selected
                              <?php } ?>>精华帖</option>
                              <option value="2" <?php if($question['level']==2){ ?>
                                  selected
                              <?php } ?>>置顶帖</option>
                        </select>
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <button class="layui-btn" lay-filter="add" lay-submit>
                    保存
                </button>
            </div>
        </form>
    </div>
    <script>
    layui.use(['layer', 'form','layedit'], function(){
      var layer = layui.layer,form = layui.form(),
      layedit = layui.layedit;
      layedit.set({
        uploadImage: {
          url: '<?php echo U("admin/questionedit/upload");?>' //接口url
          ,type: '' //默认post
        }
      });
      index = layedit.build('L_content');
       $ = layui.jquery;
       form.verify({
          title: function(value){
            if(value.length < 10){
              return '标题至少得10个字符啊';
            }
          }
        })
      form.on('submit(add)', function(data){
       data.field.content=layedit.getContent(index);
        $.ajax({
        url:'<?php echo U("admin/questionedit/edit");?>',
          type: 'POST',
          dataType: 'json',
          data: data.field,
        })
        .done(function(respones) {
          if(respones.error==0){
              layer.alert(respones.info,{icon:1},function (){
                    parent.location.reload();
                });
          }else{
                layer.alert(respones.info,{icon:6},function (){
                    layer.closeAll();
                    parent.location.reload();
                });
          }
        })
        .fail(function() {
          console.log("error");
        });

        return false;
       });
    });
    </script>
    <script>
    var _hmt = _hmt || [];
    (function() {
      var hm = document.createElement("script");
      hm.src = "https://hm.baidu.com/hm.js?b393d153aeb26b46e9431fabaf0f6190";
      var s = document.getElementsByTagName("script")[0]; 
      s.parentNode.insertBefore(hm, s);
    })();
    </script>
</body>

 <p style="color:#fff;text-align: center;">Copyright © 2017.Company name All rights X-admin </p>